package com.os.opencv.java.chapter4;

import org.opencv.core.*;

public class Lut {

    public static void main(String[] args) {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

        //矩阵mat的初始值
        byte[] b1 = new byte[]{
                1,2,3,4,5,
                2,2,3,4,5,
                3,2,3,4,5,
                4,2,3,4,5,
                5,2,3,4,5
        };
        //创建5x5的单通道矩阵
        Mat src = new Mat(5, 5, CvType.CV_8U);
        src.put(0, 0, b1);

        //创建查找表，初始值为1
        Mat lut = new Mat(new Size(256, 1), CvType.CV_8U, new Scalar(1));

        //修改查找表前10个数字的值
        byte[] b2 = new byte[]{0,11,22,33,44,55,66,77,88,99};
        lut.put(0,0,b2);

        //用查找表里的值填充输出矩阵
        Mat dst = new Mat();
        Core.LUT(src, lut, dst);

        //在控制台输出原矩阵、查找表矩阵和输出矩阵
        System.out.println("src:");
        System.out.println(src.dump());
        System.out.println("lut:");
        System.out.println(lut.dump());
        System.out.println("dst:");
        System.out.println(dst.dump());



    }
}
